﻿/**
 *	@file		CCEGLView.h
 *	@author		NeoZhang
 *	@version	v0.1
 *	@date		2013/09/03
 *	@brief		
 */


#ifndef __CC_EGLVIEW_WIN32_H__
#define __CC_EGLVIEW_WIN32_H__

#include "CCStdC.h"
#include "platform\CCEGLViewProtocol.h"

NS_CC_BEGIN

#define ccp(__X__,__Y__) cocos2d::CCPointMake((float)(__X__), (float)(__Y__))

typedef LRESULT (*CUSTOM_WND_PROC)(UINT message, WPARAM wParam, LPARAM lParam, BOOL* pProcessed);



class CC_DLL CCEGLView : public CCEGViewProtocol
{
public:
	//!	构造函数
	CCEGLView();
	//!	析构函数
	virtual ~CCEGLView();

	//!	父类需要重写的函数

	//!	强制摧毁EGL视图
	virtual void end();
	//!	获取OpenGl渲染器是否准备好
	virtual bool isOpenGLReady();
	//!	交换前后缓冲区
	virtual void swapBuffers();
	//!	
//	virtual void setFrameSize(float width, float height);
	//! 打开或关闭输入法键盘
	virtual void setIMEKeyboardState(bool bOpen);

private:
	//!	OpenGL窗口创建函数
	virtual bool create();
	//!
	bool initGL();
	//!
	void destroyGL();

public:
	virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);

	//!	win32平台函数
	HWND getHWnd();
	void resize(int width, int height);

	//!	共享OpenGL窗口
	static CCEGLView* sharedOpenGLView();

private:
	bool m_bCaptured;
	//!	窗口句柄
	HWND			m_hWnd;
	//!	
	HDC				m_hDC;
	HGLRC			m_hRC;
	bool			m_bSupportTouch;

	LPCWSTR			m_menu;
	CUSTOM_WND_PROC	m_wndproc;

	float m_fFrameZoomFactor;
};
NS_CC_END
#endif